﻿using System;
using System.Collections.Generic;
using System.Text;
using Autorun;

namespace Samples
{
    /// <summary>
    /// This class is used to test chained tasks: it is called by the class DebugTask.
    /// </summary>
    [Serializable]
    public class ChainedTask : TaskBase
    {
        #region "Constants"
        private const string CHAINED_PARAMETER = "ChainedParameter";
        #endregion

        #region "Members"
        private string _chainedParameter;
        #endregion

        #region "Overriden methods"
        protected override void InitializeParameterList()
        {
            Parameters.Add(CHAINED_PARAMETER, "UnchainedValue");
        }

        protected override void PreProcess()
        {
            if ((Parameters[CHAINED_PARAMETER] != null) && (Parameters[CHAINED_PARAMETER].Length != 0))
                _chainedParameter = Parameters[CHAINED_PARAMETER];
            else
                throw new ArgumentNullException(string.Format("The parameter {0} cannot be empty", CHAINED_PARAMETER));

            Notify(SeverityLevels.Info, string.Format("Pre-processing ({0} := {1})", CHAINED_PARAMETER, _chainedParameter));
        }

        protected override void Process()
        {
            Notify(SeverityLevels.Info, string.Format("Processing ({0} := {1})", CHAINED_PARAMETER, _chainedParameter));
        }

        protected override void PostProcess()
        {
            Notify(SeverityLevels.Info, string.Format("Post-processing ({0} := {1})", CHAINED_PARAMETER, _chainedParameter));
        }

        #endregion
    }
}
